<!-- extend from base layout -->
{% extends "base.html" %}

{% block content %}
    <h1>Sign In</h1>
    <form action="" method="post" name="login">
        {{form.hidden_tag()}}
        <p>
            Please enter your OpenID, or select one of the providers below:<br/>
            openid: {{form.openid(size=80)}}
            {% for error in form.openid.errors %}
            <span style="color: red;">error: [{{ error }}]</span>
            {% endfor %}
            <br/>
            |{% for provider in providers %}
            <a href="javascript:set_openid('{{ provider.url }}', '{{ provider.name }}');">{{ provider.name }}</a> |
            {% endfor %}
        </p>
        <p>{{form.remember_me}} Remember Me</p>
        <p><input class="btn" type="submit" value="Sign In"/></p>
    </form>

<script type="text/javascript">
    function set_openid(openid, name) {
        u = openid.search("<username>")
        if (u != -1) {
            // openid requires username
            user = prompt("Enter your " + name + " username:")
            openid = openid.substr(0, u) + user
        }
        form = document.forms["login"];
        form.elements["openid"].value = openid
    }
</script>
{% endblock %}